home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
simula
/
books
/
books.lha
/
kirkerud
/
histo2.sim
< prev
next >
Wrap
Text File
|
1993-08-16
|
1KB
|
40 lines
begin
integer least_weight_group, greatest_weight_group;
outtext("Type the least and greatest weight-group "
"containing measurements: ");
breakoutimage; inimage;
least_weight_group := inint; greatest_weight_group := inint;
begin
integer array count(least_weight_group : greatest_weight_group);
integer weight_group, asterisk_number, number_of_asterisks;
real weight;
! Read the measurements one by one: ;
outtext(" Please type the weights. "); outimage;
outtext(" Remember to type -1 after the last one!"); outimage;
weight := inreal;
while weight ge 0 do
begin
weight_group := entier(weight);
count(weight_group) := count(weight_group) + 1;
weight := inreal;
end;
! Write the histogram: ;
outtext("Weight : Number of children"); outimage;
for weight_group := least_weight_group step 1 until greatest_weight_group do
begin
outint(weight_group, 6); outtext(" : ");
number_of_asterisks := count(weight_group);
for asterisk_number := 1 step 1 until number_of_asterisks do outchar('*');
outimage;
end weight_group-repetition;
end of block with declaration of the count-array;
end of program;